﻿Public Class Company
    Implements Resetable
    Private processItemList As List(Of ProcessItem) = New List(Of ProcessItem)
    Private projectManager As ProjectManager = New ProjectManager()
    Private businessAnalist As BusinessAnalist = New BusinessAnalist()
    Private developer As Developer = New Developer()
    Private tester As Tester = New Tester()

    Sub New()
        createProjectManagementProcess()
    End Sub

    Private Sub createProjectManagementProcess()
        'Gather rq
        Dim clientMeetingCmd As Command = New Command("Meeting with Client", businessAnalist)
        Dim shortTechEstCmd As Command = New Command("Short Tech. Estim", developer)
        shortTechEstCmd.addDependency(clientMeetingCmd)
        Dim writeReqCmd As Command = New Command("Write Requirements", businessAnalist)
        writeReqCmd.addDependency(shortTechEstCmd)
        Dim gatherReqProcess As ProcessItem = New ProcessItem("Gather Requirements")
        gatherReqProcess.addCommand(clientMeetingCmd)
        gatherReqProcess.addCommand(shortTechEstCmd)
        gatherReqProcess.addCommand(writeReqCmd)
        processItemList.Add(gatherReqProcess)
        ' Estimation
        Dim baEstCmd As Command = New Command("Estimation", businessAnalist)
        baEstCmd.addDependency(writeReqCmd)
        Dim devEstCmd As Command = New Command("Estimation", developer)
        devEstCmd.addDependency(writeReqCmd)
        Dim testEstCmd As Command = New Command("Estimation", tester)
        testEstCmd.addDependency(writeReqCmd)
        Dim estimateProcess As ProcessItem = New ProcessItem("Team Estimation")
        estimateProcess.addCommand(baEstCmd)
        estimateProcess.addCommand(devEstCmd)
        estimateProcess.addCommand(testEstCmd)
        processItemList.Add(estimateProcess)
        'Develop
        Dim designFuncCmd As Command = New Command("Desing", developer)
        designFuncCmd.addDependency(devEstCmd)
        designFuncCmd.addDependency(writeReqCmd)
        Dim developFuncCmd As Command = New Command("Develop", developer)
        developFuncCmd.addDependency(designFuncCmd)
        Dim devLocalTestCmd As Command = New Command("Local Test", developer)
        devLocalTestCmd.addDependency(developFuncCmd)
        Dim developProcess As ProcessItem = New ProcessItem("Develop Functionality")
        developProcess.addCommand(designFuncCmd)
        developProcess.addCommand(developFuncCmd)
        developProcess.addCommand(devLocalTestCmd)
        processItemList.Add(developProcess)
        'Test
        Dim createTestCasesCmd As Command = New Command("Write Test Cases", tester)
        createTestCasesCmd.addDependency(testEstCmd)
        createTestCasesCmd.addDependency(writeReqCmd)
        Dim executeTestCasesCmd As Command = New Command("Execute Test Cases", tester)
        executeTestCasesCmd.addDependency(createTestCasesCmd)
        executeTestCasesCmd.addDependency(devLocalTestCmd)
        Dim writeReportCmd As Command = New Command("Write Report", tester)
        writeReportCmd.addDependency(executeTestCasesCmd)
        Dim testProcess As ProcessItem = New ProcessItem("Test")
        testProcess.addCommand(createTestCasesCmd)
        testProcess.addCommand(executeTestCasesCmd)
        testProcess.addCommand(writeReportCmd)
        processItemList.Add(testProcess)
    End Sub

    Public Sub startProcess()
        For Each ProcessItem In processItemList
            projectManager.setCommands(ProcessItem.getCommandList())
        Next
    End Sub

    Public Sub reset() Implements Resetable.reset
        projectManager.reset()
        businessAnalist.reset()
        developer.reset()
        tester.reset()
        For Each processItem In processItemList
            processItem.reset()
        Next
    End Sub

    Public Function getProcessItemList() As List(Of ProcessItem)
        Return processItemList
    End Function

    Public Function getProjectManager() As ProjectManager
        Return projectManager
    End Function

    Public Function getBusinessAnalist() As BusinessAnalist
        Return businessAnalist
    End Function

    Public Function getDeveloper() As Developer
        Return developer
    End Function

    Public Function getTester() As Tester
        Return tester
    End Function
End Class
